<?php
class Model_users extends BF_Model {
	protected $table          = 'users';
	protected $key            = 'id';
	protected $soft_deletes   = false;
	protected $date_format    = 'datetime';
	protected $set_created    = false;
	protected $set_modified   = false;
	
	function getUserDeets($id, $fname = null, $lname=null){
		$this->db->select('(achievepoints_time+achievepoints_class+achievepoints_wiki+achievepoints_forum+achievepoints_main+achievepoints_side+achievepoints_meta) AS total_points, bf_users_details.*, bf_users.*');
		$this->db->join('bf_users','bf_users.id = bf_users_details.student_id');
		if ($id != null){
			$this->db->where('student_id',$id);
		}else{
			$this->db->where('first_name',$fname);
			$this->db->where('last_name',$lname);
		}
		$q = $this->db->get('bf_users_details');
		return $q->row();
	}
	
	function getUsers(){
		$this->db->join('bf_users_details','bf_users.id = bf_users_details.student_id');
		$q = $this->db->get('bf_users');
		return $q->result();
	}
}